Function.prototype.myCall = function (context) {
    context = context || window;
    // 给context添加一个属性，指向this
    context.fn = this;
    // 获取剩余参数
    let args = [...arguments].slice(1);
    // 将剩余参数传递给这个属性
    context.fn(args)
    const result = context.fn();
    delete context.fn
    return result
}
Function.prototype.myApply = function (context, arr) {
    context = context || window;
    // 给context添加一个属性，指向this
    context.fn = this;
    // 将剩余参数传递给这个属性
    const result = context.fn(...arr);
    delete context.fn
    return result
}
Function.prototype.myBind = function (context, ...arg) {
    context = context || window;
    const _this = this;
    return function Bind(...newArg) {
        if (this instanceof Bind) {
            return _this.myApply(this, [...arg, ...newArg])
        } else {
            return _this.myApply(context, [...arg, ...newArg])
        }
    }
}
